package rsb21118.ningwei.lianxi;

import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入五个数");
        int [] score = new int [5];
        for (int i = 0; i < score.length; i++) {
            System.out.print("请输入第 " + (i + 1) + " 个数：");
            score[i] = sc.nextInt();
        }
        getMax(score);
        getMin(score);
        getAvg(score);

    }

    public static void getMax(int [] num) {
        int max = num[0];
        for (int i = 1; i < num.length; i++) {
            if (max < num[i]) {
                max = num[i];
            }
        }
        System.out.println("最大值"+max);
    }

    public static void getMin(int [] num){
        int min = num[0];
        for (int i = 1; i < num.length; i++) {
            if (min > num[i]) {
                min = num[i];

            }
        }
        System.out.println("最小值"+min);
    }

    public static void getAvg(int [] num){
        int sum = num[0];
        for (int i = 1; i < num.length; i++) {
            if(i < num.length){
                sum = sum + num[i];
            }
        }
        int avg = sum / num.length;
        System.out.println("平均值"+avg);
    }


}
